import request from '@/utils/request'

export function login(data) {
  return request({
    url: '/login',
    method: 'post',
    data: data,
    handleError:true,
  })
}

export function getInfo(token) {
  return request({
    url: '/info',
    method: 'get',
  })
}





export function logout() {
  return request({
    url: '/logout',
    method: 'post'
  })
}

/**
 * 获取用户的店铺选项
 * @returns {Promise | Promise<unknown>}
 */
export function getUserOptions(){
  return request({
    url: '/user/getUserOptions'
  })
}

export function getUserList(params = {}){
  return request({
    url: `/user/getUserList`,
    params,
  })
}

/**
 * 创建用户
 * @param data
 * @returns {Promise | Promise<unknown>}
 */
export function createUser(data){
  return request({
    url: '/user/createUser',
    method: 'post',
    data,
    handleError: true,
  })
}


/**
 * 获取用户信息
 * @param id
 * @returns {Promise | Promise<unknown>}
 */
export function getUserInfo(id){
  return request({
    url: `/user/getUserInfo/${id}`,
    method: 'get',
  })
}

/**
 * 保存用户信息
 * @param data
 * @returns {Promise | Promise<unknown>}
 */
export function saveUserInfo(data){
  return request({
    url: '/user/saveUserInfo',
    method: 'post',
    data,
    handleError: true,
  })
}

/**
 * 修改用户备注
 * @param params
 * @returns {Promise | Promise<unknown>}
 */
export function saveUserRemark(params){
  return request({
    url: `/user/saveUserRemark/${params.id}`,
    params,
    method: 'patch'
  })
}

/**
 * 获取用户的登录链接
 * @param userId
 * @returns {Promise | Promise<unknown>}
 */
export function getUserLoginUrl(userId){
  return request({
    url: `/user/getUserLoginWithKey/${userId}`,
    method: 'get',
  })
}

/**
 * 后台充值
 * @param data
 * @returns {Promise | Promise<unknown>}
 */
export function recharge(data){
  return request({
    url: '/user/recharge',
    method: 'post',
    data,
    handleError: true,
  })
}


/**
 * 获取用户的充值记录
 * @param params
 * @returns {Promise | Promise<unknown>}
 */
export function getRechargeData(params){
  return request({
    url: '/user/getRechargeData',
    params,
  })
}

/**
 * 获取充值记录列表
 * @param params
 * @returns {Promise | Promise<unknown>}
 */
export function getRechargeRecordData(params){
  return request({
    url: '/user/getRechargeRecordData',
    params,
  })
}

/**
 * 保存用户的隐藏订单数据
 * @param data
 * @returns {Promise | Promise<unknown>}
 */
export function saveUserOrderHidden(data){
  return request({
    url: '/user/saveUserOrderHidden',
    method: 'post',
    data,
    handleError: true,
  })
}

/**
 * 保存用户信息
 * @param data
 * @returns {Promise | Promise<unknown>}
 */
export function editUserInfo(data){
  return request({
    url: '/user/editUserInfo',
    method: 'post',
    data,
    handleError: true,
  })
}
/**
 * 获取用户列表
 * @param params
 * @returns {Promise | Promise<unknown>}
 */
export function getEmpolye(params = {}){
  return request({
    url: `/user/getEmpolye`,
    params,
    method: 'get',
  })
}

export function getIsShowLog(params){
  return request({
    url: `/user/getIsShowLog`,
    method: 'get',
    params:{
      ...params
    }
  })
}

export function editAdminLogShow(data){
  return request({
    url:'/user/editAdminLogShow',
    method:'post',
    handleError: true,
    data:{
      ...data
    }
  })
}
